Skip to content

[Warnings] Cleaned Up Most Warnings in GCC-13 #2700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

AlexandreSinger
Copy link
Contributor

This PR resolves several small issues which were causing warnings in the GCC13 build. Trying to get GCC13 warning clean before we upgrade the CI.

This resolves the following warnings:

  • Fixed incorrect forward declaration
  • Fixed ambiguous unique pointer allocation
  • Converted an int into a size_t
  • Fixed array access out of bounds
  • Fixed potential memory leak
  • Changed C String to STD String
  • Fixed const reference
  • Removed -lz flag from compilation
  • Added missing headers to a file

See each of the associated commits for more details.

There are still warnings coming from the nDMatrix class (discussed previously) which should be resolved in its own PR. There are also a couple of other small warnings which are slightly more complex to resolve.

In RoutePathManager, the forward declaration of the RoutingContext was
incorrectly made a class instead of a struct. This was causing several
warnings in the Clang build (but not in the GCC build). Fixed since the
forward declaration should match the declaration.
This code previously used an int to calculate the size of an allocation,
which was done by shifting a bit; however, this is technically
ill-formed since this could generate a negative value. This was causing
a warning to appear in the most recent version of GCC. Although this is
technically ok, its best that this properly uses size_t instead.
The way this section of code was written could potentially lead to an
array access out of bounds. This was causing a warning in future
versions of GCC. Simply fixed this issue.
This line of code was likely a mistake; the src of a strcpy should never
be a freshly allocated pointer. Fixed the line to likely what the coder
intended.
GCC sometimes gets confused with how strings are allocated, when they
are C strings allocated by hand. Changed to an std string since it is
easier to work with and removes the warning.
When a class returns a reference to a dereferenced pointer, if the
pointer does not point to a const object, returning that pointer as a
const has no effect. This was causing warnings.

To fix this, we want a refernece to a const object not a const reference
to an object (silly, I know). So we need to make this more clear in the
class.
@github-actions github-actions bot added VPR VPR FPGA Placement & Routing Tool lang-cpp C/C++ code build Build system lang-make CMake/Make code external_libs labels Aug 21, 2024
The -lz flag is used to link with the ZLIB library, but the library was
already being linked; so there was no reason to add the flag. This was
causing an insane number of warnings in the Clang build. If this is
added back for any reason, this should be checked.

Also cleaned up how ZLIB was being linked. ZLIB is required for reading
and processing the atom circuit; so it should always be linked with VPR.
@AlexandreSinger
Copy link
Contributor Author

@vaughnbetz This has passed CI. Please review when you have a moment. This PR is cleaning up simple warnings in GCC-13 in preparation for us upgrading the CI. Still more warnings and things to fix, but this fixes most of them.

@vaughnbetz vaughnbetz merged commit 33a82f1 into verilog-to-routing:master Aug 21, 2024
53 checks passed
@vaughnbetz
Copy link
Contributor

Thanks!

@AlexandreSinger AlexandreSinger deleted the feature-noble-warnings branch November 27, 2024 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Build system external_libs lang-cpp C/C++ code lang-make CMake/Make code VPR VPR FPGA Placement & Routing Tool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants